#!/usr/bin/env python
"""
Test of placing two dock widgets in same area. What does it do?
---------------------------------------------------------------
It works just fine, putting one above the other.

Now how do I programmatically choose the order?
-----------------------------------------------


"""
import os
import platform
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *

__version__ = "1.0.0"


class MainWindow(QMainWindow):

    def add_dock_widget(self, title, obj_name):
        logDockWidget = QDockWidget(title, self)
        logDockWidget.setObjectName(obj_name)
        logDockWidget.setAllowedAreas(Qt.LeftDockWidgetArea|
                                      Qt.RightDockWidgetArea)
        listWidget = QListWidget()
        logDockWidget.setWidget(listWidget)
        self.addDockWidget(Qt.RightDockWidgetArea, logDockWidget)
        return logDockWidget 
        
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        
        self.imageLabel = QLabel()
        self.imageLabel.setMinimumSize(200, 200)
        self.imageLabel.setAlignment(Qt.AlignCenter)
        self.setCentralWidget(self.imageLabel)
        
        self.tabs = []
        self.tabs.append( self.add_dock_widget("Log","LogDockWidget") )
        self.tabs.append( self.add_dock_widget("Log2","Log2DockWidget") )
        
        # try making tabs
        self.tabifyDockWidget( *self.tabs )
        # put them back
        self.addDockWidget( Qt.RightDockWidgetArea, self.tabs[1] )
        # remove and restore
        self.removeDockWidget( self.tabs[1] )
        self.addDockWidget( Qt.RightDockWidgetArea, self.tabs[1] )
        self.tabs[1].show()
        
        # This doesn't do it (Turns out that it splits into tabs if first element is in tabs already):
        #       self.splitDockWidget( self.tabs[0], self.tabs[1], Qt.Vertical )
        
def main():
    app = QApplication(sys.argv)
    app.setOrganizationName("JAE Software")
    app.setOrganizationDomain("jaety.com")
    app.setApplicationName("Dock Tests")
    form = MainWindow()
    form.show()
    app.exec_()
    return (app,form)


if __name__=="__main__":
    main()

